import { fetchQueryOrderStatus } from '@/api/pay';
import { useEffect, useState } from 'react';

const usePay = (props: { orderId: string }) => {
    const [payRes, setPayRes] = useState('pending');
    const orderId = props.orderId;
    useEffect(() => {
        fetchQueryOrderStatus({ orderId })
            .then((res) => {
                console.log(res);
                if (res.statusCode === 200) {
                    setPayRes('success');
                } else {
                    setPayRes('error');
                }
            })
            .catch((err) => {
                setPayRes('error');
            });
    }, []);
    return {
        payRes,
    };
};

export default usePay;
